<template>
    <div>
        <el-link type="primary" href="/mycenter/addExpert">添加</el-link>
        <el-table :data="expertsData" style="width: 100%">
            <el-table-column label="序号" type="index" width="80"></el-table-column>
            <el-table-column  label="头像" width="150">
                <template slot-scope="scope">

                    <el-avatar :src="scope.row.headImg"></el-avatar>
                </template>
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="100"></el-table-column>
            <el-table-column prop="sex" label="性别" width="80"></el-table-column>
            <el-table-column prop="company" label="单位" width="200"></el-table-column>
            <el-table-column  label="状态" width="80">
                <template slot-scope="scope">
                    <el-switch
                            v-model="scope.row.status==0?false:true"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            @change="handleStatus(scope.row)"
                    >
                    </el-switch>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="150">
                <template slot-scope="scope">
<!--                    <el-link type="primary" href="/mycenter/CheckExpert">查看</el-link>-->
                    <el-button type="text" size="small" @click="handleShow(scope.row.id)">查看</el-button>
                    <el-button type="text" size="small" @click="handleEdit(scope.row.id)">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    import Table from '@/apis';
    export default {
        name: 'expert',
        data() {
            return {
                id:1,
                expertsData: [],
                currentPage: 1,
                total: 0,
                limit: 20
            };
        },
        created() {
            this.getExpertByPage();
            // this.getCheckExpertById();
        },
        methods: {

        handleStatus(value){
            console.log(value)
            value.status=! value.status
        },
            async getExpertByPage() {
                return await Table.getExpertByPage(this.currentPage, this.limit).then(res => {
                    this.expertsData = res.data.data;
                    console.log(this.expertsData);
                });
            }
            ,
            handleShow(id){

                this.$router.push({path:'/mycenter/CheckExpert',query:{Id:id}});

            },
            handleEdit(id){
                this.$router.push({path:'/mycenter/editorExpert',query:{Id:id}});

            }


        }
    };
</script>

<style></style>
